//导入用到的组件，此文件功能同main.js
const { createApp, onMounted, ref, watch, toRefs, computed, reactive, defineAsyncComponent, getCurrentInstance } = Vue
const { createRouter, createWebHashHistory, createWebHistory } = VueRouter


const { vload } = xue
//设置xue加载的基路径
xue.config.baseUrl = '/pages'
//配置路由
const routes = [
    { path: '/', component: vload('/sys/login.html') }
    , { path: '/main', component: vload("/sys/main.html") }
    , { path: '/demo1', component: vload("/demo/demo1/index.html") },
    /*二级路由演示*/
    {
        path: '/demo2/', component: { template: `<router-view></router-view>` }
        //    ^^^^^^^^注意这里的路径前后都有 /
        , children: [
            { path: '', component: xue.vload("/demo/demo2/index.html"), alias: 'index' }
            , { path: 'add', component: xue.vload("/demo/demo2/add.html") }
            , { path: 'edit', component: xue.vload("/demo/demo2/edit.html") }
            , { path: 'view', component: xue.vload("/demo/demo2/view.html") }
        ]
    }

];
const router = createRouter({
    history: createWebHashHistory(),
    routes,
})

const app = Vue.createApp({});

// //给xue添加支持异步组件 defineAsyncComponent
const vloadc = (compPath, options) => {
    return defineAsyncComponent(xue.vload(compPath, options));
}
// // 导出全局变量
Object.assign(app.config.globalProperties, {
    //比如导出 axios
})
// // 暴露vue3的api
// // 在html中使用 let {ref} =Vue
if (window) {
    Object.assign(window.Vue, {
        vload: xue.vload, //路由加载
        vloadc           //局部组件加载
    })
}
app.use(vant)
app.use(router)
app.mount('#app')